use chrono::NaiveDateTime;
use serde::{Deserialize, Serialize};
use sqlx::FromRow;

// 搜索用的参数结构体
#[derive(Deserialize)]
pub struct SearchParams {
    pub q: Option<String>, // q 代表 query (关键词)
}

#[derive(FromRow, Deserialize, Serialize, Debug, Clone)]
#[allow(dead_code)] // <--- 添加这一行
pub struct User {
    pub id: i32,
    pub name: String,
    pub password: String, // Hashed
    pub intro: Option<String>,
}

#[derive(FromRow, Debug, Clone)]
#[allow(dead_code)] // <--- 添加这一行
pub struct Book {
    pub id: i32,
    pub user_id: Option<i32>,
    pub book_name: String,
    pub author: String,
    pub number_of_copies: i32,
    pub synopsis: Option<String>,
}

// 图书搜索结构体
#[derive(Debug, Serialize, FromRow)]
#[allow(dead_code)] // <--- 添加这一行
pub struct Books {
    pub id: i32,
    pub book_name: String,
    pub author: String,
    pub number_of_copies: i32, // 副本/数量
    pub book_state: String,    // "借出" 或 "馆藏", 联查获得
}

#[derive(FromRow, Debug, Clone)]
#[allow(dead_code)]
pub struct BorrowItem {
    pub id: i32,
    pub book_id: i32,
    pub book_name: String, // 联查获得
    pub librarian: Option<String>,
    pub borrow_datetime: Option<NaiveDateTime>,
    pub return_datetime: Option<NaiveDateTime>,
    pub book_state: String,
    pub book_preserve: i32,
}
